/**
 * 
 */
package com.hawkfly.interceptor;

import com.wbcs.config.component.application.report.ReportBean;
import com.wbcs.jbsf.util.Consts;
import com.wbcs.jbsf.util.Wbcs4JBSFUtil;
import com.wbcs.system.ReportRequest;
import com.wbcs.system.intercept.AbsInterceptorDefaultAdapter;

/**
 * 活动预告权限微控
 * @author hawkfly
 */
public class ItprActiveventeditform extends AbsInterceptorDefaultAdapter
{
    @Override
	public void doStart(ReportRequest rrequest,ReportBean rbean)
    {
        //取消自带按钮显示
        rrequest.authorize(rbean.getId(),com.wbcs.util.Consts.BUTTON_PART,"type{save}","display","false");
        rrequest.authorize(rbean.getId(),com.wbcs.util.Consts.BUTTON_PART,"type{reset}","display","false");
        rrequest.authorize(rbean.getId(),com.wbcs.util.Consts.BUTTON_PART,"type{delete}","display","false");
        
        String rolename = Wbcs4JBSFUtil.getRolenames(rrequest.getRequest().getSession().getAttribute(Consts.SESSION_ROLE));
        Object siteid = rrequest.getRequest().getSession().getAttribute(Consts.SESSION_SITEID);
        
        if(!Consts.MAINSITE.equals(siteid) && rolename.indexOf("编审") != -1)//非主站编审则写入FBR信息到request attribute中
        {
            rrequest.authorize(rbean.getId(), com.wbcs.util.Consts.BUTTON_PART, "publishCstmBtn", "display", "false");
            rrequest.authorize(rbean.getId(), com.wbcs.util.Consts.BUTTON_PART, "gobackCstmBtn", "display", "false");
            rrequest.authorize(rbean.getId(), com.wbcs.util.Consts.BUTTON_PART, "revokePublishCstmBtn", "display", "false");
            if(!"add".equals(rrequest.getStringAttribute(rbean.getId()+"_ACCESSMODE")))
            {
                rrequest.authorize(rbean.getId(), com.wbcs.util.Consts.BUTTON_PART, "craftCstmBtn", "display", "false");
                rrequest.authorize(rbean.getId(), com.wbcs.util.Consts.BUTTON_PART, "checkCstmBtn", "display", "false");
            }
        }
        else if(Consts.MAINSITE.equals(siteid) && rolename.indexOf("编审") != -1)
        {
            if("add".equals(rrequest.getStringAttribute(rbean.getId()+"_ACCESSMODE")))
            {
                rrequest.authorize(rbean.getId(), com.wbcs.util.Consts.BUTTON_PART, "publishCstmBtn", "display", "false");
                rrequest.authorize(rbean.getId(), com.wbcs.util.Consts.BUTTON_PART, "gobackCstmBtn", "display", "false");
                rrequest.authorize(rbean.getId(), com.wbcs.util.Consts.BUTTON_PART, "revokePublishCstmBtn", "display", "false");
                rrequest.authorize(rbean.getId(), com.wbcs.util.Consts.BUTTON_PART, "craftCstmBtn", "display", "false");
            }
            else
            {
                rrequest.authorize(rbean.getId(), com.wbcs.util.Consts.BUTTON_PART, "craftCstmBtn", "display", "false");
                rrequest.authorize(rbean.getId(), com.wbcs.util.Consts.BUTTON_PART, "checkCstmBtn", "display", "false");
            }
            
        }
    }
}

